import mysql.connector


def get_db_Conection() -> object:
    """
    数据库链接字符串
    Returns: 数据库链接

    """
    connection = mysql.connector.connect(
        host=f'localhost',
        user="root",
        password='123456Aa',
        database="medicinb"
    )
    return connection


def get_db():
    """
    链接数据库
    Returns: 链接数据库
    """
    connection = get_db_Conection()
    db = connection.cursor()
    try:
        yield db
    finally:
        db.close()
        connection.close()
